package per.leiyu.ssmobject.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import per.leiyu.ssmobject.mapper.UserMapper;
import per.leiyu.ssmobject.pojo.User;

import java.util.List;

/**
 * @author 雷雨
 * @date 2020/6/29 17:04
 */

/**
 * service 我们把查询的数据做分页展示
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;
    @Override
    public PageInfo<User> getUserList(int page, int limit) {
        //开启分页
        PageHelper.startPage(page,limit);
        //查询数据
        List<User> userList = userMapper.getAllUsers();
        //把查询的数据分页
        PageInfo<User> pageInfo= new PageInfo<>(userList);

        return pageInfo;
    }
}
